package com.csx.base.design.behavior.mediator;

import java.util.ArrayList;
import java.util.List;

/**
 * @author cuisongxu
 * @date 2022/10/10 11:55
 */
public abstract class ChatRoom {

    public String name;

    /**
     * 存储加入聊天室的用户们
     */
    List<User> users = new ArrayList<>();

    public ChatRoom(String name) {
        // 初始化时必须命名聊天室
        this.name = name;
    }

    protected void register(User user) {
        // 用户进入聊天室，加入列表
        this.users.add(user);
    }

    protected void deregister(User user) {
        users.remove(user);
    }

    protected abstract void sendMsg(User from, User to, String msg);

    protected abstract String processMsg(User from, User to, String msg);

}
